<?php
/**
 *
 * 版权所有：恰维网络<qwadmin.qiawei.com>
 * 作    者：寒川<hanchuan@qiawei.com>
 * 日    期：2016-01-20
 * 版    本：1.0.0
 * 功能说明：网站设置控制器。
 *
 **/

namespace Qwadmin\Controller;

class StateController extends ComController
{
    public function index()
    {

        $list = M('state')->where(['uid'=>$_SESSION['uid']])->order('id desc')->select();
        // P($list);
        $this->assign('list',$list);

        $this->display();
    }






    public function add()
    {
    	if (IS_POST) {
    		// P(I());
    		$list = $_POST;
    		$list['time'] = date('Y-m-d H:i');
    		$list['uid'] = $_SESSION['uid'];
    		if (M('state')->add($list) > 0) {
    			$this->success('申诉成功,等待处理');
    		}else{
    			$this->error('申诉失敗,重新填寫');
    		}

    	}else{
    		$ulist = M('member')->where(['uid'=>$_SESSION['uid']])->select();
    		$this->assign('ulist',$ulist);
    		$this->display();
    	}
      

        
    }





    public function xiang()
    {
    	// dump(I());
    	// exit;
    	switch ($_GET['type']) {
    		case '1':
    			$list = M('state')->where(['id'=>$_GET['id']])->select();
    			$guo = $list[0]['result'];
    			$this->assign('list',$list);
    			$this->assign('guo',$guo);
    			$this->display();
    			break;
    		case '2':
    			$type['type'] = '1';
    			if (M('state')->where(['id'=>$_GET['id']])->save($type) > 0) {
    				$this->success('已撤銷');
    			}else{
    				$this->error('撤銷失敗');
    			}
    			break;
    		
    	}
    }






    public function clist()
    {
            if ($_GET['type'] == '1') {
                $list = M('state')->where(['id'=>$_GET['id']])->select();
                // dump($list);
                // exit;
                $this->assign('list',$list);
                $this->display('chu');
            }else{
                   if ($_GET['type'] == '2') {
                            $list = M('state')->where(['id'=>$_GET['id']])->select();
                            $empty = '1';
                            $this->assign('list',$list);
                            $this->assign('empty',$empty);
                            $this->display('chu');
                   }else{
                        $list = M('state')->order('id desc')->select();
                        $this->assign('list',$list);
                        $this->display();
                   }
            }

    	
    }




    public function chu()
    {
       // dump(I());
       $result['result'] = $_POST['result'];
       $result['type'] ='2';
       if (M('state')->where(['id'=>$_POST['id']])->save($result) > 0) {
            $this->success('处理成功','clist');
       }else{
            $this->error('处理失败，请重新填写。');
       }

    
        
    }


}